package com.lg.algorithm.collections.queue.block;

import lombok.SneakyThrows;

import java.util.concurrent.LinkedBlockingDeque;

/**
 * LinkedBlockingDeque
 * 可以指定初始大小，指定大小后不能扩容；无法扩容，在put直接阻塞
 * 不指定大小，默认为Integer.MAX_VALUE。
 * 初期头节点为null
 *
 * ReentrantLock
 *
 */

public class LinkedBlockingDequeTest {
    @SneakyThrows
    public static void main(String[] args) {
        LinkedBlockingDeque<Integer> integers = new LinkedBlockingDeque<>(1);
        LinkedBlockingDeque<Integer> integers2 = new LinkedBlockingDeque<>();

        integers.putFirst(1);
        integers.putFirst(5);
        integers.putFirst(3);
        integers.putLast(7);
        integers.putLast(9);
        integers.putLast(8);

        System.out.println(integers.pollFirst());
        System.out.println(integers.pollLast());
    }
}
